<template>
    <div style="margin-top: 10px;text-align: center">
        <el-pagination
                :current-page="trueIndex"
                :page-sizes="[10, 20, 50, 100,200]"
                :page-size="pageSize"
                background
                @size-change="sizeChange"
                @prev-click="indexChange"
                @next-click="indexChange"
                @current-change="indexChange"
                layout="total, sizes, prev, pager, next, jumper"
                :total="itemsTotal">
        </el-pagination>
    </div>
</template>

<script>
    export default {
        name: "Pagination",
        props: {
            pageIndex: {
                type: Number,
                default: 0
            },
            pageSize: {
                type: Number,
                default: 10
            },
            itemsTotal: {
                type: Number,
                default: 0
            }
        },
        computed: {
            trueIndex:function () {
                return this.pageIndex + 1;
            }
        },
        methods: {
            sizeChange: function (pageSize) {
                console.log(pageSize);
                this.$emit('update:pageSize', pageSize);
                this.$emit("refresh");
            },
            indexChange: function (index) {
                console.log(index);
                this.$emit('update:pageIndex', index - 1);
                this.$emit("refresh");
            }
        }
    }
</script>

<style scoped>

</style>
